/*
 * Copyright 2003-2005 (c) Live Media Pty Ltd. <argot@einet.com.au> 
 *
 * This software is licensed under the Argot Public License 
 * which may be found in the file LICENSE distributed 
 * with this software.
 *
 * More information about this license can be found at
 * http://www.einet.com.au/License
 * 
 * The Developer of this software is Live Media Pty Ltd,
 * PO Box 4591, Melbourne 3001, Australia.  The license is subject 
 * to the law of Victoria, Australia, and subject to exclusive 
 * jurisdiction of the Victorian courts.
 */

#include "Types.h"

#include "common/BigEndianUnsignedByte.h"
#include "common/BigEndianUnsignedShort.h"
#include "common/BigEndianUnsignedInteger.h"
#include "common/BigEndianUnsignedLong.h"
#include "common/BigEndianSignedByte.h"
#include "common/BigEndianSignedShort.h"
#include "common/BigEndianSignedInteger.h"
#include "common/BigEndianSignedLong.h"
#include "common/Empty.h"
#include "common/U16ArrayByte.h"
#include "common/U32ArrayByte.h"
#include "common/U32UTF8.h"
#include "common/U8Ascii.h"
#include "common/U8Boolean.h"

#include "meta/MetaExpression.h"
#include "meta/MetaIdentified.h"

#include "TypeBindCommon.h"
 
int type_bind_common( type_library * library )
{
	int rc;
	
	if ( type_library_get_state( library, &empty_name ) == TYPE_REGISTERED )
	{
		rc = type_library_bind( library, &empty_name, &empty_read, &empty_write );
		if ( rc != TYPE_OK ) return rc;
	}
		
	/* Register Big Endian Unsigned Types. */
	if ( type_library_get_state( library, &uint8_name ) == TYPE_REGISTERED )
	{
		rc = type_library_bind( library, &uint8_name, &uint8_read, &uint8_write );
		if ( rc != TYPE_OK ) return rc;
	}

	if ( type_library_get_state( library, &uint16_name ) == TYPE_REGISTERED )
	{
		rc = type_library_bind( library, &uint16_name, &uint16_read, &uint16_write );
		if ( rc != TYPE_OK ) return rc;
	}
		
	if ( type_library_get_state( library, &uint32_name ) == TYPE_REGISTERED )
	{
		rc = type_library_bind( library, &uint32_name, &uint32_read, &uint32_write );
		if ( rc <= NOTYPE ) return rc;
	}
	
	if ( type_library_get_state( library, &uint64_name ) == TYPE_REGISTERED )
	{
		rc = type_library_bind( library, &uint64_name, &uint64_read, &uint64_write );
		if ( rc <= NOTYPE ) return rc;
	}
	
	/* Register Big Endian Signed Types. */
	if ( type_library_get_state( library, &sint8_name ) == TYPE_REGISTERED )
	{
		rc = type_library_bind( library, &sint8_name, &sint8_read, &sint8_write );
		if ( rc <= NOTYPE ) return rc;		
	}
	
	if ( type_library_get_state( library, &sint16_name ) == TYPE_REGISTERED )
	{
		rc = type_library_bind( library, &sint16_name, &sint16_read, &sint16_write );
		if ( rc <= NOTYPE ) return rc;
	}
		
	if ( type_library_get_state( library, &sint32_name ) == TYPE_REGISTERED )
	{
		rc = type_library_bind( library, &sint32_name, &sint32_read, &sint32_write );
		if ( rc <= NOTYPE ) return rc;
	}
	

	if ( type_library_get_state( library, &sint64_name ) == TYPE_REGISTERED )
	{
		rc = type_library_bind( library, &sint64_name, &sint64_read, &sint64_write );
		if ( rc <= NOTYPE ) return rc;
	}
	
	if ( type_library_get_state( library, &u8ascii_name ) == TYPE_REGISTERED )
	{
		rc = type_library_bind( library, &u8ascii_name, &u8ascii_read, &u8ascii_write );
		if ( rc <= NOTYPE ) return rc;
	}	
	
	if ( type_library_get_state( library, &u32utf8_name ) == TYPE_REGISTERED )
	{
		rc = type_library_bind( library, &u32utf8_name, &u32utf8_read, &u32utf8_write );
		if ( rc <= NOTYPE ) return rc;
	}

	if ( type_library_get_state( library, &u16binary_name ) == TYPE_REGISTERED )
	{
		rc = type_library_bind( library, &u16binary_name, &u16binary_read, &u16binary_write );
		if ( rc <= NOTYPE ) return rc;
	}
	
	if ( type_library_get_state( library, &u32binary_name ) == TYPE_REGISTERED )
	{
		rc = type_library_bind( library, &u32binary_name, &u32binary_read, &u32binary_write );
		if ( rc <= NOTYPE ) return rc;
	}
	
	if ( type_library_get_state( library, &bool_name ) == TYPE_REGISTERED )
	{
		rc = type_library_bind( library, &bool_name, &bool_read, &bool_write );
		if ( rc <= NOTYPE ) return rc;
	}
		
	if ( type_library_get_state( library, &meta_identified_name ) == TYPE_REGISTERED )
	{
		rc = type_library_bind( library, &meta_identified_name, &meta_identified_read, &meta_identified_write );
		if ( rc <= NOTYPE ) return rc;
	}
	

	/* FIXME add in date and date.java. */

	return TYPE_OK;
}

